package com.zut.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zut.mapper.FileMapper;
import com.zut.pojo.QrFile;
import com.zut.pojo.Result;
import com.zut.service.FileService;
import com.zut.utils.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author: Mr.Liu
 * @create: 2021-12-20 10:21
 */
@Service
public class FileServiceImpl implements FileService {

    @Autowired
    private FileMapper fileMapper;

    @Autowired
    private UserUtil userUtil;

    @Override
    public Result findFilesByUser(HttpServletRequest request) {
        Integer userId = userUtil.getUserId(request);
        if (userId==null){
            return Result.error("用户id为空");
        }
        return Result.success("查询成功",fileMapper.selectList(new QueryWrapper<QrFile>().eq("uuid", userId)));
    }
}
